package com.itheima06;

import java.util.Comparator;

public class Car implements Comparable<Car> {
    private String brand;
    private int price;
    private int number;

    @Override
    public int compareTo(Car o) {
        int result =o.number - this.number;
        result = (result == 0) ? o.price - this.price : result;
        result = (result == 0) ? this.brand.compareTo(o.brand) : result;
        return result;
    }

    public Car() {
    }

    public Car(String brand, int price, int number) {
        this.brand = brand;
        this.price = price;
        this.number = number;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    @Override
    public String toString() {
        return "Car{" +
                "brand='" + brand + '\'' +
                ", price=" + price +
                ", number=" + number +
                '}';
    }


}
